const install = (Vue, vm) => {
	//判断是否登录
	const isLogin = () => {
		const token = vm.$store.state.vuex_token
		//console.log(token)
		if (!token) {
			//来自哪个页面
			//获取页面栈
			const currentPage = getCurrentPages().pop()
			//获取参数
			const options = currentPage.options
			//获取参数的key
			const optionsKey = Object.keys(options)//[]
			let params = ''
			if(optionsKey.length!==0){
				params = optionsKey.reduce((pre,item)=>{
					return pre + item + '=' + options[item] + '&'
				},'?').slice(0,-1)
			}
			
			uni.setStorageSync('back_url',currentPage.route + params)
			vm.$u.toast('请登录')
			setTimeout(() => {
				uni.$u.route({
					url: '/pages/auth/login',
					type: 'redirect',
				})
			}, 1000)
		}
	}

	vm.$u.utils = {
		isLogin
	}
}
export default {
	install
}
